<?php

namespace app\api\model\activity;

use app\common\model\activity\{Order as OrderModel, Goods as GoodsModel};
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

class Order extends OrderModel
{
    /**
     * 更新状态
     * @param string $orderNo
     * @param array $status
     * @return bool
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function paySuccess(string $orderNo, array $status): bool
    {

        // 商品更新
        $order = $this->where('order_no', $orderNo)->field('order_id,order_no')->find();
        GoodsModel::update(['status' => 1], ['order_id' => $order->order_id]);
        return $order->save($status);
    }


}